Skip to content

Conversation

@dgud
Copy link
Contributor

@dgud dgud commented Oct 20, 2025

To allow array creation from any type of input, for example from binaries without the need to first create a redundant list.

@dgud dgud self-assigned this Oct 20, 2025
@dgud dgud added the team:PS Assigned to OTP team PS label Oct 20, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

CT Test Results

    2 files     97 suites   1h 7m 27s ⏱️
2 221 tests 2 170 ✅ 51 💤 0 ❌
2 610 runs  2 554 ✅ 56 💤 0 ❌

Results for commit 8f7ccf5.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@bjorng bjorng changed the title Add a array from function Add an array from function Oct 20, 2025
@josevalim
Copy link
Contributor

I wonder if it should be called from_function for consistency with the other from_* functions.

@dgud
Copy link
Contributor Author

dgud commented Oct 23, 2025

I wonder if it should be called from_function for consistency with the other from_* functions.

Thanks for the suggestion.

Discussed this but we think it is fine as it is, the other from_* discuss the input type and here it can take any user specified data
as input.

Other functions that uses a fun like map and fold doesn't specify that it takes a fun as argument.

@dgud dgud added the testing currently being tested, tag is used by OTP internal CI label Oct 24, 2025
@dgud dgud force-pushed the dgud/stdlib/array-from/OTP-19815 branch from 96771ad to 5f8b7c2 Compare October 29, 2025 13:51
@dgud dgud requested a review from Copilot October 29, 2025 13:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new from/2 and from/3 functions to the array module that create arrays by iteratively calling a function with a state until it returns done. This provides a more flexible way to construct arrays compared to from_list/1.

  • Adds array:from/2 and array:from/3 functions to build arrays from a generator function
  • Includes comprehensive test coverage with from_test_() and real-world examples in import_export/1
  • Adds doctest integration via doctests/1 test case

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/stdlib/src/array.erl Implements the from/2 and from/3 functions with documentation and helper functions
lib/stdlib/test/array_SUITE.erl Adds test cases for the new functions including unit tests, integration tests, and doctests

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dgud dgud assigned lucioleKi and unassigned lucioleKi Oct 30, 2025
@dgud dgud requested a review from lucioleKi October 30, 2025 07:36
@dgud dgud force-pushed the dgud/stdlib/array-from/OTP-19815 branch from 5f8b7c2 to 2dc2827 Compare October 30, 2025 07:44
To allow array creation from any type of input, for example from
binaries without the need to first create a redundant list.
@dgud dgud force-pushed the dgud/stdlib/array-from/OTP-19815 branch from 2dc2827 to 8f7ccf5 Compare October 30, 2025 14:03
@dgud dgud merged commit f590265 into erlang:master Oct 31, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants